# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils games

ATRIS_SOUNDS_P=atris-sounds-1.0.1
DESCRIPTION="Alizarin Tetris is a Tetris-like game with multi-player support, user-extensible color, shape and sound styles, and TCP/IP networking."
HOMEPAGE="http://www.cs.virginia.edu/~weimer/atris/"
SRC_URI="http://www.cs.virginia.edu/~weimer/atris/${P}.tar.gz
	http://www.cs.virginia.edu/~weimer/atris/${ATRIS_SOUNDS_P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND=">=media-libs/freetype-2.1.0
	>=media-libs/libsdl-1.2.0
	media-libs/sdl-ttf
	sys-devel/automake"

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${FILESDIR}/${PN}-1.0.7-install-fix.patch
	epatch ${FILESDIR}/${PN}-1.0.7-players-fix.patch
	epatch ${FILESDIR}/${PN}-1.0.7-scores-fix.patch
	aclocal || die "aclocal failed"
	automake || die "automake failed"

	# atris-sounds
	cd "${WORKDIR}/${ATRIS_SOUNDS_P}"
	epatch ${FILESDIR}/${ATRIS_SOUNDS_P}-install-fix.patch
	automake || die "automake failed"
}

src_compile() {
	egamesconf --prefix=/usr || die "econf failed"
	emake || die "emake failed"

	# atris-sounds
	cd "${WORKDIR}/${ATRIS_SOUNDS_P}"
	egamesconf --prefix=/usr || die "econf failed"
	emake || die "emake failed"
}

src_install() {
	make DESTDIR="${D}" install || die "make install failed"
	dodoc AUTHORS ChangeLog README Docs/atris.html Docs/faq.html || die "dodoc failed"
	make_desktop_entry "${PN}" "Alizarin Tetris" atris.xpm "Games;Arcade"
	insinto "${ROOT}/usr/share/pixmaps"
	newins icon.xpm atris.xpm

	# atris-sounds
	cd "${WORKDIR}/${ATRIS_SOUNDS_P}"
	make DESTDIR="${D}" install || die "make install failed"
	docinto ${ATRIS_SOUNDS_P}
	dodoc AUTHORS ChangeLog README || die "dodoc failed"
	prepgamesdirs
}
